feat(config): vaults.json schema + loader (M1a)#212
Merged
Conversation
Contributor
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ 🔗 View workflow run |
52ced1c to
a0c008a
Compare
- Zod schema (vaults.schema.ts) per cli.md section 1: local|git|couchdb
discriminated union (hard-fail on unknown type), Discover roots,
VaultsConfig with dup-name refine + cloud-path name allowlist
- Loader (vaults.ts): JSON + YAML (JSON wins), zero-config = empty,
atomic 0600 save with the canonical $schema url injected on write
- ensureVaultsConfig() scaffolds an empty, $schema-linked vaults.json when
none exists (wired into setup) so a fresh machine's file has autocomplete
- No legacy migration: a non-current-schema file fails validation loudly
- Adds zod+yaml (the exact deps of sibling memory-core), pinned (no 'latest');
R6 package guard amended
- zod-4 fix: sync blocks use .prefault({}) so inner defaults re-apply
- 85 tests green
a0c008a to
f70ce9a
Compare
vreshch
added a commit
that referenced
this pull request
Jul 5, 2026
The offline command block for **M1 - Config + registry**. Second of two PRs. **Stacked on #212** (base = `feature/m1-config-schema`) - review/merge #212 first, then this retargets to master. ## What (all offline - no network, no auth) - **`vault list [--json]`** - name / type / path, one line each (remote shown for git, server for couchdb); friendly hint when empty. - **`vault add <name>`** - `--local` (a folder that never syncs) or `--git <remote>` (`--interval`, default 5m); `--path` (default `~/vaults/<name>`, created if missing). Writes a valid entry, provisions nothing. - **`vault remove <name>`** - unregisters + drops `~/.agentage/index/<name>.db`; markdown stays on disk. - **`update [--check]`** - `--check` reports the verdict; otherwise `npm i -g @agentage/cli@latest` when the registry says we're behind (installer injected for tests). Passive check already rides `status`. - `vault-registry.ts` holds the pure add/remove/index-path/format logic; commands take injected `Deps`. ## Deferred (not in this PR) - **couchdb-default `vault add`** (the account path) - `vault add` with no flag errors with guidance. It needs `POST /vaults` provisioning + the **V4 couch-channel** call, so it lands in the provisioning slice. - Publishing `vaults.schema.json` on the landing (separate landing-repo PR). ## Verify - `npm run verify` green: type-check (src + e2e), eslint, prettier, **109 unit tests**, build. - **Ran the built binary end to end** (temp config dir): add `--local`/`--git`, list + `--json`, duplicate -> exit 1, no-flag -> "needs provisioning" exit 1, remove leaves files, `vaults.json` written valid with `$schema` first + git sync defaults filled. - **Offline e2e tier (@p0)** passes locally (`npx playwright test vault-offline`, 2 passed): add -> list -> remove with no network. ## Verify (for you) Open the diff; optionally `npm run build && node dist/cli.js vault add demo --local --path /tmp/demo && node dist/cli.js vault list`.
vreshch
added a commit
that referenced
this pull request
Jul 5, 2026
E2E hardening for **M1** - covers every M1 acceptance criterion with end-to-end tests. **Stacked on #213** (base = `feature/m1b-vault-commands`); lands after #212 -> #213. Adds `e2e/m1-requirements.test.ts` (@p0), driving the built `dist/cli.js` against a per-test temp config dir. All offline except `update --check` (which the verb tolerates on any network state). ## Coverage (9 tests) | Requirement | Test | |---|---| | `vault add --git` writes a valid entry (interval + `$schema`) | ✓ | | `--git` requires a remote value | ✓ | | duplicate name rejected | ✓ | | allowlist-failing name rejected | ✓ | | **empty `vaults.json` still carries the `$schema` link** | ✓ | | `remove` keeps markdown on disk, drops the index db | ✓ | | `vaults.yaml` accepted; JSON wins when both exist | ✓ | | malformed / unknown-type config fails loudly | ✓ | | `update --check` reports a verdict, exits 0, never installs | ✓ | ## Verify - `npx playwright test m1-requirements vault-offline` -> **11 passed** locally (9 new + 2 from #213), 3.1s. - `type-check:e2e` + `format:check` green. Stack merge order: **#212 -> #213 -> this**. CI runs once the stack rebases onto master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of two PRs for M1 - Config + registry (see the cli feature plan). Pure config layer: schema + loader. No commands, no network, no legacy migration.
What
vaults.schema.ts- the normative Zod schema from cli.md §1:local | git | couchdbdiscriminated union (hard-fail on unknown type),Discoverroots,VaultsConfigwith a duplicate-name refine and the^[A-Za-z0-9_-]{1,64}$cloud-path-segment name allowlist.$schemais written on create + accepted-and-ignored on load.vaults.ts- loader: readsvaults.jsonthenvaults.yaml(JSON wins), zero-config = empty config, atomic0600save that always rewrites the canonical$schemaurl.Decisions
vaults.json(memory-core 0.1.0 / Agentage Sync 0.2.3) is not migrated - a file that isn't the current array schema fails validation loudly. Users start fresh with the new schema /vault add. (Removes the cross-repo writer-coordination gate and themcp-key call entirely.)zod+yaml- the exact runtime deps of the sibling@agentage/memory-core. R6 package-guard amended to match; the set grows again with the daemon at M3.syncblocks use.prefault({})(not.default({})) - zod 4 stopped re-parsing defaults, so.default({})would leavesync: {}unfilled.Verify
npm run verifygreen: type-check (src + e2e), eslint, prettier, 83 unit tests, build.ignore: []= sync-everything, JSON+YAML load, JSON-wins, zero-config empty, atomic 0600 save round-trip + canonical$schemarewrite, and legacy-file rejection.Follow-up (M1b, stacked next):
vault list,vault add --local,vault add --git <remote>,vault remove, and theupdateverb (all offline). The couchdb-defaultvault add+POST /vaultsprovisioning waits on the V4 couch-channel call.